﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfAppraisal.aspx.cs" MasterPageFile="~/Site.master"
    Inherits="WSBulTasDesa.wfAppraisal" EnableEventValidation="false" Culture="Auto"
    UICulture="Auto" %>

<%@ Register Src="UserControls/ucLocation.ascx" TagName="ucLocation" TagPrefix="uc1" %>
<%@ Register Src="UserControls/ucRegion.ascx" TagName="ucRegion" TagPrefix="uc2" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Tasaciones
    </h2>
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"
        EnableScriptGlobalization="true" EnableScriptLocalization="true">
    </asp:ScriptManager>
    <table width="100%" cellpadding="0" cellspacing="-1">
        <tr>
            <td width="50%" valign="top">
                <table style="width: 100%;">
                    <tr>
                        <td>
                            Nombre Establecimiento
                        </td>
                        <td>
                            <asp:TextBox ID="txtEstablishmentName" runat="server" SkinID="txtLongString"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvEstablishmentName" runat="server" ControlToValidate="txtEstablishmentName"
                                Display="None" ErrorMessage="Ingrese nombre estableciomiento."></asp:RequiredFieldValidator>
                            <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="vceEstablishmentName" TargetControlID="rfvEstablishmentName"
                                Width="250px" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Nomenclatura Catastral
                        </td>
                        <td>
                            <asp:TextBox ID="txtCatastralNomenclature" runat="server" SkinID="txtLongString"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Carpeta Nro.</td>
                        <td>
                            <asp:TextBox ID="txtFolderNumber" runat="server" SkinID="txtLongString"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Dueño
                        </td>
                        <td>
                            <asp:TextBox ID="txtOwner" runat="server" SkinID="txtLongString"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvOwner" runat="server" ControlToValidate="txtOwner"
                                ErrorMessage="Ingrese dueño." Display="None"></asp:RequiredFieldValidator>
                            <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="vceOwner" TargetControlID="rfvOwner"
                                Width="200px" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Contacto
                        </td>
                        <td>
                            <asp:TextBox ID="txtContact" runat="server" SkinID="txtLongString"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Teléfono
                        </td>
                        <td>
                            <asp:TextBox ID="txtOwnerTel" runat="server" SkinID="txtString"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Mail
                        </td>
                        <td>
                            <asp:TextBox ID="txtOwnerMail" runat="server" SkinID="txtLongString"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Has
                        </td>
                        <td>
                            <asp:TextBox ID="txtHa" runat="server" MaxLength="11" SkinID="txtHa"></asp:TextBox>
                            <ajaxToolkit:FilteredTextBoxExtender ID="ftbHa" runat="server" TargetControlID="txtHa"
                                FilterType="Custom, Numbers" ValidChars="." />
                            <asp:RegularExpressionValidator ID="revHa" runat="server" ControlToValidate="txtHa"
                                ErrorMessage="Número decimal fuera del rango establecido" Display="None" ValidationExpression="^[0-9]{1,6}(\.[0-9]{0,4})?$"></asp:RegularExpressionValidator>
                            <asp:RequiredFieldValidator ID="rfvHa" runat="server" ControlToValidate="txtHa" ErrorMessage="Ingrese Has."
                                Display="None"></asp:RequiredFieldValidator>
                            <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="vceHa" TargetControlID="rfvHa"
                                Width="200px" />
                            <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="vceHaBis" TargetControlID="revHa"
                                Width="200px" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Distancia Bs. As.
                        </td>
                        <td>
                            <asp:TextBox ID="txtDistanceBA" runat="server" MaxLength="4" SkinID="txtDistance"></asp:TextBox>km
                            <ajaxToolkit:FilteredTextBoxExtender ID="ftbDistanceBA" runat="server" TargetControlID="txtDistanceBA"
                                FilterType="Custom, Numbers" />
                            <asp:RequiredFieldValidator ID="rfvDistanceBA" runat="server" ControlToValidate="txtDistanceBA"
                                ErrorMessage="Ingrese distancia Bs. As." Display="None"></asp:RequiredFieldValidator>
                            <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="vceDistanceBA" TargetControlID="rfvDistanceBA"
                                Width="200px" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Fecha Revisión
                        </td>
                        <td>
                            <asp:TextBox ID="txtRevisionDate" runat="server"></asp:TextBox>
                            <ajaxToolkit:CalendarExtender ID="calRevisionDate" runat="server" Format="d MMMM yyyy"
                                TargetControlID="txtRevisionDate">
                            </ajaxToolkit:CalendarExtender>
                            <asp:RequiredFieldValidator ID="rfvDateRevision" runat="server" ControlToValidate="txtRevisionDate"
                                ErrorMessage="Ingrese fecha revisión." Display="None"></asp:RequiredFieldValidator>
                            <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="vceDateRevision" TargetControlID="rfvDateRevision"
                                Width="200px" />
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">
                            Revisor
                        </td>
                        <td>
                            <asp:CheckBoxList ID="chkRevisor" runat="server" RepeatColumns="2" BorderStyle="Solid"
                                BorderWidth="1px" CellPadding="0" CellSpacing="0">
                            </asp:CheckBoxList>
                            <asp:CustomValidator ClientValidationFunction="ValidateCheckList" ID="rfvRevisor"
                                runat="server" ErrorMessage="Ingrese al menos un revisor." ForeColor="Red"> </asp:CustomValidator>
                        </td>
                    </tr>
                </table>
            </td>
            <td valign="top">
                <uc2:ucRegion ID="ucRegion" runat="server" />
                <uc1:ucLocation ID="ucLocation" runat="server" />
                <uc1:ucLocation ID="ucLocationPC" runat="server" />
                <uc1:ucLocation ID="ucLocationPL" runat="server" />
            </td>
        </tr>
    </table>
    <div align="right">
        <asp:UpdatePanel ID="upSave" UpdateMode="Conditional" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
            </Triggers>
            <ContentTemplate>
                <asp:Button ID="btnSave" runat="server" OnClientClick="disableSubmit();return false"
                    Text="Guardar"/>
                <asp:Panel runat="server" ID="pnlConfirm" Style="display: none;" class="popupConfirmation">
                    <div class="popup_Container">
                        <div class="popup_Titlebar">
                            <div class="TitlebarLeft">
                                Guardar Tasación</div>
                            <div class="TitlebarRight" onclick="$get('ButtonConfirmCancel').click();">
                            </div>
                        </div>
                        <div class="popup_Body">
                            <p align="center">
                                Confirma guardar Tasación?
                            </p>
                        </div>
                        <div class="popup_Buttons">
                            <asp:Button ID="ButtonConfirmOkay" runat="server" Text="Aceptar" />
                            <asp:Button ID="ButtonConfirmCancel" runat="server" Text="Cancelar" />
                        </div>
                    </div>
                </asp:Panel>
                <asp:Button ID="HiddenButton" runat="server" Text="Hiddenbutton" Style="display: none;"
                    OnClick="btnHidden_Click" />
                <ajaxToolkit:ConfirmButtonExtender ID="btnSave_ConfirmButtonExtender" runat="server"
                    DisplayModalPopupID="extConfirm" TargetControlID="HiddenButton" BehaviorID="ConfirmButtonBehavior">
                </ajaxToolkit:ConfirmButtonExtender>
                <ajaxToolkit:ModalPopupExtender ID="extConfirm" runat="server" PopupControlID="pnlConfirm"
                    TargetControlID="HiddenButton" CancelControlID="ButtonConfirmCancel" OkControlID="ButtonConfirmOkay"
                    BackgroundCssClass="ModalPopupBG" />
                <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
                <asp:Panel ID="pnlMsg" runat="server" Style="display: none" class="popupConfirmation">
                    <div class="popup_Container">
                        <div class="popup_Titlebar" id="PopupHeader">
                            <div class="TitlebarLeft">
                                Mensaje</div>
                            <div class="TitlebarRight" onclick="$get('btnClose').click();">
                            </div>
                        </div>
                        <div class="popup_Body">
                            <p align="center">
                                La Tasación se ha guardado correctamente.
                            </p>
                        </div>
                        <div class="popup_Buttons">
                            <asp:Button ID="btnAcceptMsg" runat="server" Text="Aceptar" />
                            <asp:Button ID="btnCloseMsg" runat="server" Text="Cancelar" />
                        </div>
                    </div>
                </asp:Panel>
                <ajaxToolkit:ModalPopupExtender ID="extMsg" runat="server" TargetControlID="btnShowPopup"
                    PopupControlID="pnlMsg" CancelControlID="btnCloseMsg" BackgroundCssClass="ModalPopupBG" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <script type="text/javascript">
        function disableSubmit() {
            if (typeof (Page_ClientValidate) == 'function') {
                if (Page_ClientValidate() == true) {
                    return checkSubmit();
                }
                else {
                    return true;
                }
            }
            else {
                return checkSubmit();
            }
        }

        function checkSubmit() {
            var confirmButton = $find('ConfirmButtonBehavior');
            confirmButton._displayConfirmDialog();

        }

        function ValidateCheckList(source, args) {
            var chkRevisor = document.getElementById('<%= chkRevisor.ClientID %>');
            var chkListinputs = chkRevisor.getElementsByTagName('input');
            for (var i = 0; i < chkListinputs.length; i++) {
                if (chkListinputs[i].checked) {
                    args.IsValid = true;
                    return;
                }
            }
            args.IsValid = false;
        }
    </script>
</asp:Content>
